﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/admin/admin.Master" CodeBehind="CycleCount.aspx.vb" Inherits="UI.CycleCount" %>

<%@ Import Namespace="Telerik.Web.UI" %>
<%@ Import Namespace="Telerik.Web.UI.Skins" %>
<%@ Import Namespace="KOR.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <style type="text/css">
        .searchDiv {
            min-height: 60px;
            vertical-align: middle;
        }

        .searchBox {
            float: left;
            /*min-width: 100px;*/
            padding: 5px;
        }
    </style>


    <div class="row">
        <div class="span12">
            <div class="widget ">
                <div class="widget-header">
                    <i class="icon-user"></i>
                    <h3>Product Inventory</h3>
                </div>
                <!-- /widget-header -->
                <div class="widget-content">
                    <div class="tabbable">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="#jscontrols" data-toggle="tab">Product Stock Status</a></li>
                        </ul>

                        <br />
                        <div class="searchDiv">
                            <div class="searchBox">
                                Keyword
                                <br />
                                <asp:TextBox runat="server" ID="txtKeywords"></asp:TextBox>
                            </div>

                            <div class="searchBox">
                                Brand
                                <br />
                                <asp:DropDownList runat="server" ID="ddlBrands"></asp:DropDownList>
                            </div>

                            <div class="searchBox" style="text-align: center;">
                                Frozen
                                <br />
                                <asp:CheckBox runat="server" ID="chkFrozen" />
                            </div>

                            <div class="searchBox" style="text-align: center;">
                                Processed
                                <br />
                                <asp:CheckBox runat="server" ID="chkProcessed" />
                            </div>

                            <div class="searchBox" style="text-align: center;">
                                <br />
                                <asp:Button runat="server" ID="btnSearch" Text="Search" />
                            </div>

                            <div class="searchBox" style="text-align: center;">
                                <br />
                                <asp:Button runat="server" ID="btnPostAll" Text="Process All" />
                            </div>

                        </div>
                        <div style="clear: both;"></div>
                        <div class="tab-content ">
                            <div class="tab-pane  active" id="jscontrols">
                                <fieldset>
                                    <br />

                                    <telerik:RadGrid runat="server" ID="rgProductInventory" ViewStateMode="Disabled" DataSourceID="odsStock" Width="100%"
                                        EnableEmbeddedSkins="false" MasterTableView-EditMode="InPlace" AllowPaging="True" AllowSorting="True"
                                        AutoGenerateColumns="False">

                                        <MasterTableView runat="server" PageSize="50" ClientDataKeyNames="ProductID, DetailID, InventorySessionID" DataSourceID="odsStock"
                                            DataKeyNames="ProductID, DetailID" AllowMultiColumnSorting="true">
                                            <HeaderStyle BorderStyle="None" HorizontalAlign="Center" Font-Bold="true" Font-Underline="true" BackColor="Wheat" ForeColor="Black" />
                                            <ItemStyle BorderStyle="None" HorizontalAlign="Center" />
                                            <AlternatingItemStyle BorderStyle="None" HorizontalAlign="Center" />
                                            <EditItemStyle BorderStyle="None" HorizontalAlign="Right" />

                                            <Columns>

                                                <telerik:GridTemplateColumn HeaderText="Product" SortExpression="ProductName" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:LinkButton ID="lblProduct" runat="server" Text='<%# ValueOrDefault(Eval("ProductName"), "").ToString()%>' CommandName="ShowDetails" CommandArgument='<%# CDbl(ValueOrDefault(Eval("ProductID"), 0))%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridTemplateColumn HeaderText="Stock" SortExpression="Stock" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right">
                                                    <ItemStyle Width="100px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:Label ID="lbStock" runat="server" Text='<%# ValueOrDefault(Eval("OriginalQuantity"), 0)%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

                                                <telerik:GridTemplateColumn HeaderText="Counted" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                                    <ItemStyle Width="90px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <%--<asp:TextBox runat="server" ID="txtCountedQty" Width="80px"></asp:TextBox>--%>
                                                            <telerik:RadNumericTextBox runat="server" ID="txtCountQty" Width="70px" AutoPostBack="true" 
                                                                Value='<%# CDbl(ValueOrDefault(Eval("CountedQuantity"), 0))%>' DisplayText='<%# ValueOrDefault(Eval("CountedQuantity"), 0)%>'
                                                                EnabledStyle-HorizontalAlign="Right" OnTextChanged="txtFrozen_TextChanged">
                                                            </telerik:RadNumericTextBox>
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

                                                <telerik:GridTemplateColumn HeaderText="Adjusted" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                                    <ItemStyle Width="120px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:Label ID="lbAdjusted" runat="server" Text='<%# ValueOrDefault(Eval("Difference"), 0)%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

                                                <telerik:GridTemplateColumn HeaderText="Counted Date" SortExpression="CountedDate" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemStyle Width="140px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:Label ID="lblCountedDate" runat="server" Text='<%# FormatDateTime(CDate(ValueOrDefault(Eval("CountedDate"), Nothing))).ToString()%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

                                                <telerik:GridTemplateColumn HeaderText="Processed Date" SortExpression="PostedDate" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemStyle Width="140px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:Label ID="lbPostedDate" runat="server" Text='<%# FormatDateTime(CDate(ValueOrDefault(Eval("PostedDate"), Nothing)).ToShortDateString).ToString()%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>

                                                <telerik:GridTemplateColumn HeaderText="" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemStyle Width="30px" />
                                                    <ItemTemplate>
                                                        <div style="font-size: 12px; margin-top: 5px;">
                                                            <asp:ImageButton runat="server" ID="ibFreeze" Visible="false" ImageUrl="~/admin/img/freeze12.png" ToolTip="Freeze" CommandName="Freeze" CommandArgument='<%# ValueOrDefault(Eval("DetailID"), 0)%>' />
                                                            <asp:ImageButton runat="server" ID="ibProcess" ImageUrl="~/admin/img/process12.png" ToolTip="Process" CommandName="Process" CommandArgument='<%# ValueOrDefault(Eval("DetailID"), 0)%>' />
                                                        </div>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                            </Columns>

                                        </MasterTableView>

                                        <ClientSettings>
                                            <Selecting AllowRowSelect="true" />
                                            <ClientEvents OnRowDblClick="SearchGridRowDoubleClick" />
                                        </ClientSettings>

                                    </telerik:RadGrid>

                                    <asp:ObjectDataSource ID="odsStock" runat="server" EnablePaging="true" TypeName="UI.BL.InventoryAdjustments"
                                        SelectMethod="GetInventoryAdjustmentDetails" SelectCountMethod="GetInventoryAdjustmentDetailsCount" SortParameterName="SortBy">
                                        <SelectParameters>
                                            <asp:Parameter Name="searchFor" DefaultValue="" Type="String" />
                                            <asp:Parameter Name="criteria" DefaultValue="" Type="String" />
                                        </SelectParameters>
                                    </asp:ObjectDataSource>

                                    <div class="form-actions" style="padding-top: 30px;"></div>
                                </fieldset>
                            </div>
                            <div class="tab-pane" id="formcontrols">
                                <fieldset>

                                    <div class="control-group">
                                        <label class="control-label" for="username">Product </label>
                                        <div class="controls">
                                            <asp:DropDownList runat="server" ID="ddlProducts" DataTextField="ProductName" DataValueField="ProductID" DataSourceID="odsProducts"></asp:DropDownList>
                                            <asp:ObjectDataSource ID="odsProducts" runat="server" TypeName="UI.BL.Products"
                                                SelectMethod="GetAllProducts"></asp:ObjectDataSource>
                                        </div>
                                        <!-- /controls -->
                                    </div>

                                    <div class="control-group">
                                        <label class="control-label" for="username">Quantity </label>
                                        <div class="controls">
                                            <asp:TextBox runat="server" ID="txtQuantity"></asp:TextBox>
                                        </div>
                                        <!-- /controls -->
                                    </div>

                                    <!-- /control-group -->
                                    <br />
                                    <div class="form-actions">
                                        <asp:Button runat="server" ID="btnSave" CssClass="btn btn-primary" Text="Save" />
                                        <asp:Button runat="server" ID="btnCancel" CssClass="btn" Text="Cancel" />
                                    </div>
                                    <!-- /form-actions -->
                                </fieldset>
                            </div>


                        </div>
                    </div>
                </div>
                <!-- /widget-content -->
            </div>
            <!-- /widget -->
        </div>
        <!-- /span8 -->
    </div>

    <telerik:RadAjaxLoadingPanel runat="server" ID="ralpRefresh" InitialDelayTime="100">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManagerProxy ID="rampBuilding" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgProductInventory">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgProductInventory" LoadingPanelID="ralpRefresh" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <%--<telerik:AjaxSetting AjaxControlID="btnCancel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlControls" LoadingPanelID="ralpRefresh" />
                </UpdatedControls>
            </telerik:AjaxSetting>--%>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

</asp:Content>
